package com.sgb.kjwl.pop;

import android.content.Context;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.sgb.kjwl.R;
import com.sgb.kjwl.view.widget.MaxHeightRecyclerView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;

/**
 * 订单动态弹窗
 * @author cyj
 */
public abstract class SimpleTile1Pop<T> extends BasePopWindow<T> {

    protected TextView mTitle;

    public SimpleTile1Pop(Context context) {
        super(context, DIR_DOWN_UP);
    }

    /**
     * 获取adapter实例
     * @return    BaseRecycleAdapter
     */
    protected abstract BaseRecycleAdapter<T> getAdapter();

    @Override
    protected int popLayout() {
        return R.layout.pop_simple_title_1;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        mTitle = holder.getPop().findViewById(R.id.title);
        holder.getPop().findViewById(R.id.close).setOnClickListener(v -> dismiss());
        MaxHeightRecyclerView maxHeightRecyclerView = holder.getPop().findViewById(R.id.recyclerView);
        maxHeightRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        maxHeightRecyclerView.setAdapter(getAdapter());
    }

}
